﻿using System.Collections.Generic;
using System.Linq;

namespace ZQNB.Entity.UI
{
    public class Row
    {
        public Row()
        {
            this.Zones = new List<Zone>();
        }

        public virtual IList<Zone> Zones { get; set; }

        public virtual int ItemOrder { get; set; }

        public virtual string CssClass { get; set; }

        public virtual string InlineStyle { get; set; }


        public virtual void AddZone(Zone zone)
        {
            zone.Row = this;
            zone.ItemOrder = Zones.Count == 0
                ? 0
                : Zones.OrderByDescending(x => x.ItemOrder).Select(x => x.ItemOrder).FirstOrDefault() + 1;
            this.Zones.Add(zone);
        }
    }
}